<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
  <script src="//cdn.bootcss.com/immutable/3.8.1/immutable.min.js"></script>
  <script>
    // 不可变性
    var app = {
      name: "wei",
      age: 24
    };
    app.name = "yi";       // 这样做会导致app.name改变
    console.log(app.name); // => yi

    // 原生方法
    var app = {
      name: "wei",
      age: 24
    };
    // 我们需要app.name保持不变
    // JS方法很多最快方法
    var app2 = Object.assign({},app,{
      name: "yi"
    }); // => { name: "yi", age: 24 }
    console.log(app,app2); // => Object {name: "wei", age: 24} Object {name: "yi", age: 24}

    // immutable方法
    var app = Immutable.Map({
      name: "wei",
      age: 24
    });
    var app2 = app.updateIn(["name"],function (d) {
      return "yi";
    });
    console.log(app.toJS(),app2.toJS()); // => Object {name: "wei", age: 24} Object {name: "yi", age: 24}

  </script>
  </body>
</html>
